<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="/WEB-INF/taglib/c.tld" %>
<%@ taglib uri="/WEB-INF/taglib/fn.tld" prefix="fn" %>
<%    
String path = request.getContextPath();    
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";    
pageContext.setAttribute("basePath",basePath);    
%>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>i HelloWorld</title>
<base href="<%=basePath %>" />
<link rel="stylesheet" type="text/css" href="js/easyui/themes/default/easyui.css"/>
<link rel="stylesheet" type="text/css" href="js/easyui/themes/icon.css"/>
<script type="text/javascript" src="js/jquery-2.0.3.js"></script>
<script type="text/javascript" src="js/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="js/easyui/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="js/ueditor/ueditor.all.js"></script>
<script type="text/javascript" src="js/ueditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
$(document).ready(function(e) {
    UE.getEditor('editor');
    //UE.getEditor('myEditor').setHeight(600);
    $("#catagory").combobox({
    	url:'admin/common/catagory.do',
		method:'get',
		valueField:'id',
		textField:'name',
		panelHeight:300
    });
});
function publish(){
	var title=$("#title").val();
	var catagoryId=$("#catagory").combobox("getValue");
	var tag=$("#tag").val();
	var summary=$("#summary").val();
	var content=UE.getEditor('editor').getContent();
	if(title==""){
		alert("请输入标题");
	}else if(catagoryId==""){
		alert("请选择目录");
	}else if(summary==""){
		alert("请输入内容");
	}else if(content==""){
		alert("请输入摘要");
	}else{
		$.post("admin/article/add.do",{title:title,summary:summary,tag:tag,content:content,catagoryId:catagoryId},function(data){
			alert("发布成功");
		});
	}
}
function openImport(){
	$("#import").dialog("open");
}
</script> 
</head>

<body>
	<div style="margin-bottom: 20px;">
		<div style="display:inline-block;">
			<label>标题：</label>
			<input id="title" type="text"/>
		</div>
		<div style="display:inline-block;">
			<label>所属目录：</label>
			<input id="catagory" type="text"/>
		</div>
		<div style="display:inline-block;">
			<a href="javascript:void(0)" onclick="">导入</a>
		</div>
		<div>
			<label>标签：</label>
			<input id="tag" type="text"/>
		</div>
		<div>
			<label>摘要：</label>
			<textarea id="summary" style="width:90%;height:50px;resize:none;" name="summary"></textarea>
		</div>
	</div>
	<script id="editor" type="text/plain" style="width:100%;height:400px;"></script> 
	<div style="margin-top:20px;">
		<input type="button" value="发表文章" onclick="publish()"/>
	</div>
	<div id="import" class="easyui-dialog" title="文章导入" style="width:400px;height:200px;"
data-options="closed:true,resizable:false,modal:true">
		<div>
			<label>网站来源：</label>
			<select id="fromSite" class="easyui-combobox">
				<option>iteye</option>
				<option>csdn</option>
			</select>
		</div>
		<div>
			<label>网址：</label>
			<input id="fromUrl" type="text"/>
		</div>
	</div>
</body>
</html>
